
Page({

  /**
   * 页面的初始数据
   */
  data: {
    schema:[],
    formData: {
      url: '',
      url2: ''
    },
    title: '',
    result: '',
    remark: '',
    webUrl: '',
    apiName: '',
    showPrivacy: false
  },
  onUnload() {
  },
  onLoad(options) {
    const that = this;
    console.log('options', options)
    wx.setNavigationBarTitle({
      title: options.title,
    })
    
    this.setData({
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
    if(options.zh === 'wx.openStickerSetView') {
      this.setData({
        schema: [
          {
            label:'表情专辑链接，可前往表情开放平台，在详情页中的「小程序跳转链接」入口复制',
            prop:'url',
            type:'text'
          },
        ]
      })
    }
    if(options.zh === 'wx.openStickerIPView') {
      this.setData({
        schema: [
          {
            label:'表情IP合辑链接，可前往表情开放平台，在详情页中的「小程序跳转链接」入口复制',
            prop:'url2',
            type:'text'
          },
        ]
      })
    }
    if(options.zh === 'wx.openSingleStickerView') {
      this.setData({
        schema: [
          {
            label:'表情链接，可前往表情开放平台，在详情页中的「小程序跳转链接」入口复制',
            prop:'url3',
            type:'text'
          },
        ]
      })
    }
  },
  getFormData(e) {
    console.log('formdata==', e.detail.formData);
    this.setData({
      formData: e.detail.formData
    })
  },
  openStickerSetView(e) {
    const that = this;
    wx.openStickerSetView({
      url: "http://weixin.qq.com/jumpemoticonstore?token=AAshJxQFAAABAAAAAACGAzmQTe1FR1%2F1cyw1aBAAAABQfF0uS5S5suWyaDJKBpGHKPPRzss3g%2FoVOEmJx4vHwPZ14z2WcZesMRD3jnAoT9lM8dkWeaipp73g3sNPMqxCovtABVt%2Fs3HKitJvFCugqWAN%2BexWT1y8TqFgnfpPO6%2FfuGx3BP%2BxTZBd0npNShfr4eHIz4smRpV7",

      success(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  openStickerIPView(e) {
    const that = this;
    wx.openStickerIPView({
      url: this.data.formData.url2,
      success(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  openSingleStickerView(e) {
    const that = this;
    wx.openSingleStickerView({
      url: this.data.formData.url3,
      success(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  }
})